<?php
/**
 * Created by PhpStorm.
 * User: admin
 * Date: 2016/9/9
 * Time: 15:35
 */
if (!defined('ACCESS')) {
    exit('Access denied.');
}

class ShopConfig extends DBBase
{

    private static $table_name = 'store';
    // 查询字段
    private static $columns = array(
        'id',
        'title',
        'kewords',
        'description',
        'width',
        'height',
        'min_height',
        'store_footer',
        'advert_imgs');

    public static function getTableName()
    {
        return self::$table_name;
    }


    public static function getConfig()
    {
        $db = self::__instance();
        $shop = $db->get(self::getTableName(), self::$columns);
        if ($shop) {
            return $shop;
        }
        return array();
    }


    public static function getDefProdImages()
    {
        $db = self::__instance();
        $products = $db->get(self::getTableName(), self::$columns);

        if ($products) {
            $imgs = $products['advert_imgs'];
            $def_img = explode("||", $imgs);
            foreach ($def_img as $img) {
                $img_ts = parse_url($img,PHP_URL_PATH);
                if (!$img_ts) {
                    $def_imgs[] = COLOR_IMG . $img;
                } else {
                    $def_imgs[] = $img;
                }
            }
            return $def_imgs;
        }
        return array();
    }
}